import time, threading


def thread_entry(begin, end):
    for i in range(begin, end):
        time.sleep(1)
        print(i)


t0 = threading.Thread(target=thread_entry, args=(1, 4), name="demo")
t1 = threading.Thread(target=thread_entry, args=(101, 104), name="test")
t0.start()
t1.start()
print(t0.is_alive(), t1.is_alive())
print(threading.current_thread())
print(threading.enumerate(), threading.active_count())
t0.join()
t1.join()
print(t0.is_alive(), t1.is_alive())


class MyThread(threading.Thread):
    def __init__(self, begin, end):
        threading.Thread.__init__(self)
        self.begin = begin
        self.end = end

    def run(self):
        for i in range(self.begin, self.end):
            time.sleep(1)
            print(i)


t0 = MyThread(1, 4)
t1 = MyThread(101, 104)
t0.start()
t1.start()
t0.join()
t1.join()
